const { no, ok } = require('../../utils/utlis');
const musicService = require('../../services/admin/musicService');
module.exports = {
	list: async (req, res, next) => {
		try {
			let { keywords } = req.body;
			let list = await musicService.list(keywords);
			res.send(ok(list));
		} catch (error) {
			res.send(no(error.message));
		}
	},
	add: async (req, res, next) => {
		try {
			let { title, author, url, pic, lrc } = req.body;
			await musicService.add(title, author, url, pic, lrc);
			res.send(ok());
		} catch (error) {
			res.send(no(error.message));
		}
	},
	edit: async (req, res, next) => {
		try {
			let { title, author, url, pic, lrc, id } = req.body;
			await musicService.edit(title, author, url, pic, lrc, id);
			res.send(ok());
		} catch (error) {
			res.send(no(error.message));
		}
	},
	detail: async (req, res, next) => {
		try {
			let { id } = req.body;
			let obj = await musicService.detail(id);
			res.send(ok(obj));
		} catch (error) {
			res.send(no(error.message));
		}
	},
	del: async (req, res, next) => {
		try {
			let { id } = req.body;
			await musicService.del(id);
			res.send(ok());
		} catch (error) {
			res.send(no(error.message));
		}
	}
};
